// pages/home/home.js
var app = getApp()
Page({
 data: {
  winWidth: 0,
  winHeight: 0,
  // tab切换 
  currentTab: 0,
  // 列表
  listData:[
    {"code":"01","text":"text1","type":"type1"},
    {"code":"02","text":"text2","type":"type2"},
    {"code":"03","text":"text3","type":"type3"},
    {"code":"04","text":"text4","type":"type4"},
    {"code":"05","text":"text5","type":"type5"},
    {"code":"06","text":"text6","type":"type6"},
    {"code":"07","text":"text7","type":"type7"}
  ]
 },
 onLoad: function () {
  wx.setNavigationBarTitle({
    title: "查询预约"
  });
  var that = this;
  wx.getSystemInfo({
   success: function (res) {
    that.setData({
     winWidth: res.windowWidth,
     winHeight: res.windowHeight
    });
   }
  });
  var token = wx.getStorageSync('token')
  var username = wx.getStorageSync('username')
  wx.request({
    url: 'http://localhost:8080/system/appointment/list?username=' + username, // 获取所有预约接口
    method: 'get',
    header: {
      'content-type': 'application/json',  //这里注意POST请求content-type是小写，大写会报错  
      'Authorization': token
    },
    success(res) {
      // 赋值给listData
      that.setData({
        listData: res.data.rows
      })
    }
  })
 },
 
 
 bindChange: function (e) {
 
  var that = this;
  that.setData({ currentTab: e.detail.current });
 
 },
 
 swichNav: function (e) {
 
  var that = this;
 
  if (this.data.currentTab === e.target.dataset.current) {
   return false;
  } else {
   that.setData({
    currentTab: e.target.dataset.current
   })
  }
 }
})